package com.ruoyi.equipment.service.impl;

import com.ruoyi.equipment.domain.LgCamera;
import com.ruoyi.equipment.domain.LgSubCold;
import com.ruoyi.equipment.mapper.LgCameraMapper;
import com.ruoyi.equipment.service.LgCameraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @Author: lek
 * @Description: TODO
 * @Date: 2025/3/7 14:52
 * @Version: 1.0
 */
@Service
public class LgCameraServiceImpl implements LgCameraService {
    @Autowired
    private LgCameraMapper lgCameraMapper;

    /**
     * @author maisan
     * @description 查找摄像头信息
     * @createTime  2025/3/7 14:53
     * @param [com.ruoyi.equipment.domain.LgCamera]
     * @return java.util.List<com.ruoyi.equipment.domain.LgCamera>
     **/
    @Override
    public List<LgCamera> selectLgCameraList(LgCamera lgCamera) {
        return lgCameraMapper.selectLgCameraList(lgCamera);
    }

    /**
     * @author maisan
     * @description //TODO 插入摄像头信息
     * @createTime  2025/3/7 18:40
     * @param [com.ruoyi.equipment.domain.LgCamera]
     * @return int
     **/

    @Override
    public int insertLgCamera(LgCamera lgCamera) {
        return lgCameraMapper.insert(lgCamera);
    }
    /**
     * @author maisan
     * @description //TODO 查找摄像头信息
     * @createTime  2025/3/7 18:42
     * @param [java.lang.Integer]
     * @return com.ruoyi.equipment.domain.LgCamera
     **/


    @Override
    public LgCamera selectLgCameraById(Integer id) {
        return lgCameraMapper.selectLgCameraById(id);
    }

    /**
     * @author maisan
     * @description //TODO 更新摄像头信息
     * @createTime  2025/3/7 18:40
     * @param [com.ruoyi.equipment.domain.LgCamera]
     * @return int
     **/


    @Override
    public int updateLgCamera(LgCamera lgCamera) {
        return lgCameraMapper.updateById(lgCamera);
    }

    /**
     * @author maisan
     * @description //TODO 删除摄像头信息
     * @createTime  2025/3/7 18:40
     * @param [java.lang.Integer[]]
     * @return int
     **/


    @Override
    public int deleteLgCameraById(Integer[] id) {
        for (int i = 0; i < id.length; i++){
            LgCamera lgCamera = lgCameraMapper.selectLgCameraById(id[i]);
            lgCamera.setId(id[i]);
            lgCamera.setColdStorageId(0);
            //删除时解车辆
            lgCameraMapper.updateById(lgCamera);
        }
        return lgCameraMapper.deleteBatchIds(Arrays.asList(id));
    }
    /**
     * @author maisan
     * @description 获取绑定的冷酷信息
     * @createTime  2025/3/8 11:00
     * @param
     * @return
     **/
    @Override
    public LgSubCold selectSubColdById(Integer id) {
        return lgCameraMapper.selectSubColdById(id);
    }
}
